/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-07-24 09:12:27
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2025-04-03 11:48:08
 * @FilePath: /etws-sxk2307/src/packetResolver/waveCmdV1.cpp
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */
#include <string>
#include <iostream>
#include "waveCmdV1.h"
#include "Common.h"


using namespace std;

std::map<int32_t, CallbackCmdFun> waveCallbackMap = {
    {0x00020000,wave_callback_0},
    {0x00020001,wave_callback_1},
    {0x00020002,wave_callback_2},
    {0x00020003,wave_callback_3},

};

void waveProtocolAnalysis(struct cmdDataType* cmd,uint8_t * cmdData)
{
    // 解析指令
    int32_t cmdId = (((uint32_t)cmd->cmdType << 16) | cmd->cmdChildType);
    if ((cmd->dst_DevType == CurDeviceType) || (cmd->dst_DevType == allDevice)) {
        if (((cmd->dst_DevNum == ComponentNO) || (cmd->dst_DevNum == allDevice))) {
            ;
        } else {
            qlog_e("命令中的主指令:%d,子指令:%d",cmd->cmdType,cmd->cmdChildType);
            qlog_e("设备类型:%d,设备编号:%d,与本设备不符",cmd->dst_DevType,cmd->dst_DevNum);
            return;
        }
    } else {
        return;
    }
    qlog_i("接收到波形类命令");
    qlog_hexdump("wave cmd",16,(uint8_t *)cmd,sizeof(struct cmdDataType));
    qlog_hexdump("wave data",16,cmdData,cmd->dataLen);
    // 解析数据
    auto it = waveCallbackMap.find(cmdId);
    if (it != waveCallbackMap.end()) {
        it->second(cmd, cmdData);
    } else {
        qlog_e("这个波形控制命令未实现..");
    }
}